/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: Dec 31, 2009
 * Time: 10:42:12 AM
 * To change this template use File | Settings | File Templates.
 */
import java.util.Hashtable;
import org.jdom.Element;

// Referenced classes of package dk.brics.dsd:
//            InternalSchemaErrorException, Definition, Schema, Validator

class Reference
{

    Reference(Element element, Schema schema)
    {
        definitions = schema.definitions;
        ref = element.getAttributeValue("ref");
        if(ref == null)
        {
            throw new InternalSchemaErrorException();
        } else
        {
            orig_ref = ref;
            ref = Schema.replacePrefix(ref, element);
            return;
        }
    }

    Definition resolve()
    {
        Validator.debug("resolving " + ref);
        Definition definition = (Definition)definitions.get(ref);
        if(definition == null)
            throw new InternalSchemaErrorException(ref);
        else
            return definition;
    }

    Hashtable definitions;
    String ref;
    String orig_ref;
}

